package com.punai.config.controller.indicatoritem;

import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.core.page.TableDataInfo;
import com.punai.common.utils.PageUtils;
import com.punai.config.service.IndicatorItemService;
import com.punai.config.sqlitedomain.ConfigIndicatorItem;
import com.punai.config.sqlitedomain.vo.ConfigIndicatorItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 指标项配置总控制器
 */
@RestController
@RequestMapping("/config/indicatorItem")
public class ConfigIndicatorItemController extends BaseController {
    @Autowired
    private IndicatorItemService indicatorItemService;
    /**
     * 查询指标项列表
     */
    @PreAuthorize("@ss.hasPermi('config:indicatorItem:dataList')")
    @GetMapping("/getDataList")
    public TableDataInfo list(ConfigIndicatorItemVo vo) {
        startPage();
        return indicatorItemService.getMainTableData(vo);
    }

    /**
     * 查询指标项详情
     * @param vo
     * @return
     */
    @PreAuthorize("@ss.hasPermi('config:indicatorItem:info')")
    @GetMapping("/getInfo")
    public AjaxResult info(ConfigIndicatorItemVo vo) {
        ConfigIndicatorItemVo info = indicatorItemService.getInfo(vo);
        return AjaxResult.success(info);
    }

    /**
     * 查询下一个指标项编码
     * @return
     */
    @PreAuthorize("@ss.hasPermi('config:indicatorItem:nextCode')")
    @GetMapping("/getNextCode")
    public AjaxResult nextCode() {
        return AjaxResult.success("成功",indicatorItemService.getNextCode());
    }


    /**
     * 保存指标项
     *
     * @param vo
     * @return
     */
    @PreAuthorize("@ss.hasPermi('config:indicatorItem:save')")
    @PostMapping("/save")
    public AjaxResult save(ConfigIndicatorItemVo vo) {
        return AjaxResult.success(indicatorItemService.save(vo));
    }

    /**
     * 删除指标项
     *
     * @param vo
     * @return
     */
    @PreAuthorize("@ss.hasPermi('config:indicatorItem:remove')")
    @PostMapping("/remove")
    public AjaxResult remove(ConfigIndicatorItemVo vo) {
        return AjaxResult.success(indicatorItemService.remove(vo));
    }

    /**
     * 设置转换系数
     *
     * @param vo
     * @return
     */
    @PreAuthorize("@ss.hasPermi('config:indicatorItem:settingUnitConver')")
    @PostMapping("/settingUnitConver")
    public AjaxResult settingUnitConver(ConfigIndicatorItemVo vo) {
        return AjaxResult.success(indicatorItemService.settingUnitConver(vo));
    }

    /**
     * 设置匹配排除规则
     *
     * @param vo
     * @return
     */
    @PreAuthorize("@ss.hasPermi('config:indicatorItem:settingMatchingRules')")
    @PostMapping("/settingMatchingRules")
    public AjaxResult settingMatchingRules(ConfigIndicatorItemVo vo) {
        return AjaxResult.success(indicatorItemService.settingMatchingRules(vo));
    }
}
